/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;
//<editor-fold defaultstate="collapsed" desc=" các thư viện sử dụng">
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;


//</editor-fold>
/**
 *
 * @author KingofSpeed
 */
  //<editor-fold defaultstate="collapsed" desc=" Class để set max length cho text field ">
class JTextFieldLimit extends PlainDocument 
    {
          private int limit;
          JTextFieldLimit(int limit) 
          {
            super();
            this.limit = limit;
          }

          JTextFieldLimit(int limit, boolean upper) 
          {
            super();
            this.limit = limit;
          }

          public void insertString(int offset, String str, javax.swing.text.AttributeSet attr) throws BadLocationException 
          {
            if (str == null)
              return;

            if ((getLength() + str.length()) <= limit) 
            {
              super.insertString(offset, str, attr);
            }
          }
    }
  //</editor-fold>
